//
//  PlayViewController.m
//  HumorousSript
//
//  Created by 李欢 on 15/6/19.
//  Copyright (c) 2015年 李欢. All rights reserved.
//

#import "PlayViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#define Width [UIScreen mainScreen].bounds.size.width
#define Height [UIScreen mainScreen].bounds.size.height
@interface PlayViewController ()
@property (strong, nonatomic) MPMoviePlayerController *streamPlayer;
@end

@implementation PlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor blackColor]];
    NSURL *streamURL = [NSURL URLWithString:_url];
    self.streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];
    [self.streamPlayer.view setFrame:CGRectMake(0, 50/667.0*Height, self.view.frame.size.width, 400/667.0*Height)];
    self.streamPlayer.controlStyle = MPMovieControlStyleEmbedded;
//    NSLog(@"nnnnnnnnnnnnn%@",self.streamPlayer);
    
    
    
    [self.view addSubview: self.streamPlayer.view];
    [self.streamPlayer play];
    
    //监听一个通知，点击done后直接退出
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitFullScreen:) name: MPMoviePlayerDidExitFullscreenNotification object:nil];
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)exitFullScreen:(NSNotification *)notification{
    [self.streamPlayer.view removeFromSuperview];
    NSLog(@"remove player");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
